﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;
using System.Drawing;

public partial class Inventory_MaterialSynchronization : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void lbtnProcess_Logistic_Click(object sender, EventArgs e)
    {
        List<string> list = new List<string>();
        foreach (GridViewRow row in GridView1.Rows)
        {
            CheckBox chk = (CheckBox)row.FindControl("chkLogistic");
            if (chk != null)
            {
                if (chk.Checked)
                {
                    list.Add("''" + row.Cells[1].Text + "''");
                }
            }
        }
        if (list.Count > 0)
        {
            string m_MaterialIDs = string.Join(",", list.ToArray());
            Inventory.InsertMaterials(m_MaterialIDs);
            this.GridView1.DataBind();
        }

    }
    protected void lbtnProcessAll_Logistic_Click(object sender, EventArgs e)
    {
        List<string> list = new List<string>();
        foreach (GridViewRow row in GridView1.Rows)
        {
            list.Add("''" + row.Cells[1].Text + "''");
        }
        if (list.Count > 0)
        {
            string m_MaterialIDs = string.Join(",", list.ToArray());
            Inventory.InsertMaterials(m_MaterialIDs);
            this.GridView1.DataBind();
        }
    }
    protected void lbtnProcess_SMS_Click(object sender, EventArgs e)
    {
        List<string> list = new List<string>();
        foreach (GridViewRow row in GridView2.Rows)
        {
            CheckBox chk = (CheckBox)row.FindControl("chkSMS");
            if (chk != null)
            {
                if (chk.Checked)
                {
                    list.Add("''" + row.Cells[1].Text + "''");
                }
            }
        }
        if (list.Count > 0)
        {
            string m_MaterialIDs = string.Join(",", list.ToArray());
            Inventory.ChangedMaterialsStatus(m_MaterialIDs);
            this.GridView2.DataBind();
        }
    }
    protected void lbtnProcessAll_SMS_Click(object sender, EventArgs e)
    {
        List<string> list = new List<string>();
        foreach (GridViewRow row in GridView2.Rows)
        {

            list.Add("''" + row.Cells[1].Text + "''");
        }
        if (list.Count > 0)
        {
            string m_MaterialIDs = string.Join(",", list.ToArray());
            Inventory.ChangedMaterialsStatus(m_MaterialIDs);
            this.GridView2.DataBind();
        }
    }
    protected bool IsVisible(string src,string target)
    {
        if (src.Equals(target))
        {
            return false;
        }
        return true;
    }
}
